package config

import (
	"fmt"
	"io/ioutil"
	"path/filepath"

	yaml "gopkg.in/yaml.v2"
)

var configFile []byte

func init() {
	absPath, _ := filepath.Abs("config/config.yaml")
	var err error
	configFile, err = ioutil.ReadFile(absPath)
	if err != nil {
		fmt.Println("yamlFile.Get err #", err)
	}
}

type AppConfig struct {
	Application Application `yaml:"application"`
}

type Application struct {
	Name string `yaml:"name"`
}

func GetAppConfig() (c *AppConfig, err error) {
	err = yaml.Unmarshal(configFile, &c)
	return c, err
}
